<template>

	<div class="login-container">
      <div class="login_logo">
        <img src="../../../assets/images/login/spsmts_logo.png" alt="安全生产教育培训综合管理平台" />
      </div>
      <div class="login_bg">
          <div class="login_box">
            <h1>账号登录</h1>
            <p style="padding:10%;">
              <Input class="login-input username" v-model="loginUser.username" icon="person" placeholder="请输入账号" type="text"  @on-enter="testLogin"></Input>
            </p>
            <p style="padding: 0% 10%;">
              <Input class="login-input password" v-model="loginUser.password" icon="android-lock" placeholder="请输入密码" type="password"  @on-enter="testLogin"></Input>
            </p>
            <div style="color:red; word-wrap:break-word;margin-bottom: 12px;padding-left: 12%;">{{ error }}&nbsp;</div>
            <Button class="login-button" shape="circle" @click="testLogin">登录</Button>
          </div>
      </div>
	</div>
</template>

<script type="text/ecmascript-6">
	export default {
		data() {
			return {
				loginUser: {
					username: '',
					password: '',
					companyName: null,
					companyId: null
				},
				error: null,
				single: false
			}
		},
		mounted() {},
		methods: {
			//点击登陆
			testLogin() {
       return location.href = '/dashboard';
				if(this.loginUser.username == '' || this.loginUser.password == '') {
					this.error = '用户名或密码不能为空'
					return;
				}
				this.$http.post('/login', {
					staffCode: this.loginUser.username,
					password: this.loginUser.password,
				}).then(res => {

					var resBody = res.body
					var code = resBody.code;
					var msg = resBody.message
					if(code == 200) { //success
						console.log("登录成功");
						return location.href = '/dashboard';

					}
					this.error = msg
				})

			},
		}
	}
</script>

<style scoped>
  body, html {
    width: 100%;
    height: 100%;
    font: normal 100% Helvetica, Arial, sans-serif;
  }

  .login-container{
    width:100%;
    height:100%;
    position: relative;
  }
  .login_bg {
    width:100%;
    background-image: url("/images/login/spsmts_bg.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;
    height:41.375rem;
    position: relative;
    margin-top: 7%;
  }
  .login_logo{
    display: inline-block;
    height:10rem;
    width:100%;


  }
  .login_logo img{
    display: inline-block;
    width:774px;
    height:58px;
    position: absolute;
    top: 15%;
    left: 6%;
  }
  .login_box{
    position: absolute;
    left: 63%;
    top: 16%;
    width: 18.3%;
    height: 55.4%;
    background: #fff;
  }
  .login_box h1{
    height: 14.6%;
    background: #1d76a5;
    padding: 8px 30px;
    color: #fff;
    font-size: 16px;
  }
  .login-button{
    border-radius: 5px;
    width: 81%;
    margin-left: 10%;
    background: #55b7ea;
    color: #fff;
  }
  @media screen and (max-width: 780px) {
    .login_logo img {
      display: inline-block;
      width:100%;
    }
    .login_bg{
      background-size:100% 100%;
    }
  }





  @media screen and (max-width: 412px) {
    .login_logo img {
      display: inline-block;
      width:100%;
    }
    .login_bg{
      background-size:100% 100%;
    }
  }

  @media screen and (max-width: 360px) {
    .login_logo img {
      display: inline-block;
      width:100%;
    }
    .login_bg{
      background-size:100% 100%;
    }
  }
  @media screen and (max-width: 320px) {
    .login_logo img {
      display: inline-block;
      width:100%;
    }
    .login_bg{
      background-size:100% 100%;
    }
  }







  @media screen and (max-width: 250px) {
    .login_logo img {
      display: inline-block;
      width: 80%;
      height: 2%;
      position: absolute;
      top: 6rem;
      left: 1rem;
    }
    .login_bg{
      background-size:100% 100%;
    }
    .login_box{
      width: 200px;
      position: absolute;
      right: 2rem;
      top: 10rem;
    }
  }
</style>
